package com.ruoyi.web.controller.personnel;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.personnel.domain.SysUserAssets;
import com.ruoyi.personnel.service.ISysUserAssetsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 固定资产管理Controller
 * 
 * @author ruoyi
 * @date 2022-03-19
 */
@Api("固定资产管理Controller")
@RestController
@RequestMapping("/personnel/userassets")
public class SysUserAssetsController extends BaseController
{
    @Autowired
    private ISysUserAssetsService sysUserAssetsService;

    /**
     * 查询固定资产管理列表
     */
    @ApiOperation("查询固定资产管理列表")
    @PreAuthorize("@ss.hasPermi('personnel:userassets:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserAssets sysUserAssets)
    {
        startPage();
        List<SysUserAssets> list = sysUserAssetsService.selectSysUserAssetsList(sysUserAssets);
        return getDataTable(list);
    }

    /**
     * 导出固定资产管理列表
     */
    @ApiOperation("导出固定资产管理列表")
    @PreAuthorize("@ss.hasPermi('personnel:userassets:export')")
    @Log(title = "固定资产管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUserAssets sysUserAssets)
    {
        List<SysUserAssets> list = sysUserAssetsService.selectSysUserAssetsList(sysUserAssets);
        ExcelUtil<SysUserAssets> util = new ExcelUtil<SysUserAssets>(SysUserAssets.class);
        util.exportExcel(response, list, "固定资产管理数据");
    }

    /**
     * 获取固定资产管理详细信息
     */
    @ApiOperation("获取固定资产管理详细信息")
    @PreAuthorize("@ss.hasPermi('personnel:userassets:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysUserAssetsService.selectSysUserAssetsById(id));
    }

    /**
     * 新增固定资产管理
     */
    @ApiOperation("新增固定资产管理")
    @PreAuthorize("@ss.hasPermi('personnel:userassets:add')")
    @Log(title = "固定资产管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserAssets sysUserAssets)
    {
        return toAjax(sysUserAssetsService.insertSysUserAssets(sysUserAssets));
    }

    /**
     * 修改固定资产管理
     */
    @ApiOperation("修改固定资产管理")
    @PreAuthorize("@ss.hasPermi('personnel:userassets:edit')")
    @Log(title = "固定资产管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserAssets sysUserAssets)
    {
        return toAjax(sysUserAssetsService.updateSysUserAssets(sysUserAssets));
    }

    /**
     * 删除固定资产管理
     */
    @ApiOperation("删除固定资产管理")
    @PreAuthorize("@ss.hasPermi('personnel:userassets:remove')")
    @Log(title = "固定资产管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysUserAssetsService.deleteSysUserAssetsByIds(ids));
    }
}
